class NativeTextViewFactory: NSObject, FlutterPlatformViewFactory {
    private var messenger: FlutterBinaryMessenger

    init(messenger: FlutterBinaryMessenger) {
        self.messenger = messenger
        super.init()
    }

    func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol {
        return FlutterStandardMessageCodec.sharedInstance()
    }

    func create(
        withFrame frame: CGRect,
        viewIdentifier viewId: Int64,
        arguments args: Any?
    ) -> FlutterPlatformView {
        return NativeTextView(frame, viewId: viewId, args: args)
    }
}


class NativeTextView: NSObject, FlutterPlatformView {
    let label = UILabel()

    init(_ frame: CGRect, viewId: Int64, args: Any?) {
        super.init()
        if let dict = args as? [String: Any], let text = dict["text"] as? String {
            label.text = text
        }
        label.frame = frame
        label.backgroundColor = UIColor.red
    }

    func view() -> UIView {
        return label
    }
    
    deinit {
        print("NativeTextView deallocated")
      }
}
